package rentalstore;

public class Movie {

    public static final int REGULAR = 0;
    public static final int NEW_RELEASE = 1;
    public static final int CHILDRENS = 2;
    public static final int LITERATURE = 3;

    private String title;
    private int priceCode;
    private Price price;

    public Movie(String title, int priceCode) {
        this.title = title;
        setPriceCode(priceCode);
    }

    public int getPriceCode() {
        return priceCode;
    }

    public void setPriceCode(int priceCode) {
        this.priceCode = priceCode;
        switch (priceCode) {
            case REGULAR:
                this.price = new RegularPrice(); break;
            case NEW_RELEASE:
                this.price = new NewReleasePrice(); break;
            case CHILDRENS:
                this.price = new ChildrensPrice(); break;
            case LITERATURE:
                this.price = new LiteraturePrice(); break;
        }
    }

    public String getTitle() {
        return title;
    }

    public double computeAmount(int dayRented) {
        return this.price.computeAmount(dayRented);
    }

    public double computeFrequentRenterPoints(int dayRented) {
        if((this.getPriceCode() == Movie.NEW_RELEASE) && dayRented > 1){
            return 2;
        }
        if (this.getPriceCode() == Movie.LITERATURE) {
            return 1.5;
        }
        return 1;
    }

}
